#include "GameMessage.h"
#include "GameMessageFactory.h"
#include "Game.h"

GameMessage::GameMessage()
{}

GameMessage::~GameMessage()
{}

GameMessage* GameMessage::Read(SockMessage* sm)
{
	std::string type;
	float timestamp=0;
	sm->ReadString(&type);
	sm->ReadFloat(&timestamp);
	GameMessage* gm = TheGameMessageFactory::Instance()->Create(type);
	gm->SetTimestamp(timestamp);
	gm->ReadFromSocketM(sm);
	return gm;
}

bool GameMessage::Write(SockMessage* sm)
{
	sm->WriteString(GetName());
	sm->WriteFloat(TheGame::Instance()->GetTime());
	WriteToSocketM(sm);
	return true;
}
void GameMessage::SetTimestamp(float f)
{
	m_Timestamp=f;
}
float GameMessage::GetTimestamp()
{
	return m_Timestamp;
}